package com.utils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AppUtil {
	
	
	/*
	 * grid返回数据使用
	 * @data 数据源
	 * @total  总数量
	 * */
	 public static Map<String, Object> buildJSONDataResponse(List<? extends Object> data, Long total) throws Exception {

	        Map<String, Object> map = new HashMap<String, Object>();

	        map.put("totalCount", total);
	        map.put("rows", data);
	        return map;
	    }
	 
	 /**
		 * 返回错误信息字符串
		 * 
		 * @param ex
		 *            Exception
		 * @return 错误信息字符串
		 */
		public static String getExceptionMessage(Exception ex) {
			StringWriter sw = new StringWriter();
			PrintWriter pw = new PrintWriter(sw);
			ex.printStackTrace(pw);
			return sw.toString();
		}
}
